In JavaScript, the delete
operator is used to remove a property from an object. If the property is successfully deleted, it returns true
; otherwise, it returns false
.
delete
operator works on object properties, not on variables or function names.true
.true
(because there’s nothing to delete).false
.
If you use delete
on an array element, it creates an empty slot instead of shifting the elements:
delete
only works on object properties.var
, let
, or const
does not work: